export default (arr, key) => {
	if (!String.prototype.localeCompare) return null
	let letters = 'abcdefghjklmnopqrstwxyz'.split('')
	let zh = '阿八嚓哒妸发旮哈讥咔垃痳拏噢妑七呥扨它穵夕丫帀'.split('')
	let segs = []
	letters.forEach((letter, i) => {
		let cur = { letter, data: [] }

		arr.forEach((item) => {
			const string = item[key]
			if (
				string.localeCompare(zh[i]) >= 0 &&
				string.localeCompare(zh[i + 1]) < 0
			) {
				cur.data.push(item)
			}
		})
		if (cur.data.length) {
			cur.data.sort(function (a, b) {
				return a[key].localeCompare(b[key], 'zh')
			})
			segs.push(cur)
		}
	})
	return segs
}
